using UnityEngine;

public class PlayerAimSwordState : PlayerState
{
    public PlayerAimSwordState(Player player, string animBoolName) : base(player, animBoolName) { }

    public override void Enter()
    {
        base.Enter();
        player.SkillManager.Sword.DotsActive(true);
    }

    public override void Exit()
    {
        base.Exit();

        _ = player.StartCoroutine("BusyFor", 0.1f);
    }

    public override void Update()
    {
        base.Update();

        player.SetVelocityToZero();

        if (Input.GetKeyUp(KeyCode.Mouse1))
        {
            StateMachine.ChangeState(player.IdleState);
        }

        Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        if (player.transform.position.x > mousePosition.x && player.FacingDirection == 1)
        {
            player.Flip();
        }
        else if (player.transform.position.x < mousePosition.x && player.FacingDirection == -1)
        {
            player.Flip();
        }
    }
}
